package com.itheima.blockingquene.shengchanxiaofei;

import com.itheima.shengchanxiaofei.Desk;

import java.util.concurrent.ArrayBlockingQueue;

/*
生产者
 */
public class Cooker extends Thread {
    public static int count=10;
    private ArrayBlockingQueue<String> list;

    public Cooker() {
    }

    public Cooker(ArrayBlockingQueue<String> list) {
        this.list = list;
    }

    @Override
    public void run() {
        while (true){
            if(count==0){
                break;
            }else {
                try {
                    list.put("汉堡包");
                    System.out.println(
                            "厨师做了一个汉堡"
                    );
                    count--;
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }

    }
}
